<template>
    <div class="ui grid form refund-auditfc">
        <div class="row ">
            <div class="eight wide column">
                <table class="ui celled table">
                    <tbody>
                    <tr v-for="item in orderList">
                        <td><span class="ui small header">{{item.name}}</span></td>
                        <td v-if="item.map">{{item.map[item.value]}}</td>
                        <td v-else>{{item.value}}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="eight wide column">
                <h3 class="ui header">操作</h3>
                <h4 class="ui header">退款审核</h4>
                <div class="ui selection dropdown">
                    <i class="dropdown icon"></i>
                    <div class="default text">同意</div>
                    <div class="menu">
                        <div class="item" v-for="item in selectArray" @click="dropdown(item)">{{item.name}}</div>
                    </div>
                </div>
                <h4 class="ui header">备注</h4>
                <div class="ui form">
                    <div class="field">
                        <textarea v-model="refundMsg"></textarea>
                    </div>
                </div>
                <div class="marginTop10">
                    <button class="ui primary button" @click="auditRefund">提交</button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import tool from 'src/util/tool';
    import util from '_util/index';
    import logic from '_logic';
    export default {
        props: ['id'],
        data(){
            return {
                selectArray: [
                    {name: '同意', value: 1},
                    {name: '拒绝', value: 2}
                ],
                dropdownSelect: {name: '同意', value: 1},
                refundMsg: '',
                orderData: {},
                orderList: {
                    sp_order_num: {name: '订单号码', value: ""},
                    qd_name: {name: '渠道', value: ""},
                    sp_name: {name: '供应商', value: ""},
                    tzu_name: {name: '服务者', value: ""},
                    user_name: {name: "用户", value: ""},
                    city:{name:'城市',value:''},
                    pname: {name: '商品名称', value: ""},
                    pay_money: {name: "支付金额", value: 0},
                    pnum: {name: '数量', value: 0},
                    /*退款金额 手续费*/
                    refund_money: {name: '退款金额', value: 0},
                    sp_fee: {name: '手续费', value: 0},
                    fc_server: {name: '服务者分成', value: 0},
                    fc_server_up: {name: '场景分成', value: 0},
                    fc_sp: {name: '供应商分成', value: 0},
                    refund_remark: {name: '用户备注', value: ''},
                },
            }

        },
        watch: {
            id: function () {
                this.getOrderDetail()
            }
        },
        created(){
            this.getOrderDetail();
        },
        methods: {
            dropdown(json){
                this.dropdownSelect = json
            },
            hideMypop(){
                this.$store.state.global.eventVue.$emit('hideMypop')
            },
            getOrderDetail(){
                this.refundMsg = '';
                util.http.getDataCom(this, tool.getApi(this, 'Refundorders', 'read'), {id: this.id}, (rs) => {
                    this.orderData = rs;
                    Object.keys(this.orderList).forEach(item => {
                        this.orderList[item].value = this.orderData[item]
                    });
                    $('.ui.dropdown').dropdown()
                })
            },
            auditRefund(){
                let url = tool.getApi(this, 'Op', 'refund_op');
                let parm = {
                    id: this.id,
                    type: this.dropdownSelect.value,
                    remark: this.refundMsg
                };
                if (parm.type === 2 && parm.remark === '') {
                    util.showMsg(this, 'info', '请填写备注');
                } else {
                    util.http.SR(this, url, parm, '审核成功', (rs) => {
                        logic.list.refreshListData(this);
                        this.hideMypop()
                    });
                }

            }
        }
    }
</script>

<style lang="less" rel="stylesheet/less" scoped>
    .refund-auditfc {
        margin: 0 !important;
        .row {
            .column {
            }
        }

    }
</style>
